var express = require('express');
var router = express.Router();
const comTcDao = require("../dao/com_tc_dao");
/**
 * 获取满足条件的题材,题材名可以模糊查询
 */
router.get('/list/:offset/:limit/:tc_name*?', async function (req, res, next) {
    const offset = req.params.offset
    const limit = req.params.limit
    const tc_name = req.params.tc_name
    const users = await comTcDao.findAll(offset, limit, tc_name)
    console.log(users)
    const resData = {
        code: 0,
        msg: 'success',
        count: users.count,
        offset: parseInt(offset),
        data: users.rows
    }
    res.send(resData);
});

/**
 * 获取指定代码的题材信息,由于题材数量一般不多,所以不分页
 */
router.get('/list/:stock_code', async function (req, res, next) {
    const stock_code = req.params.stock_code
    const users = await comTcDao.findAllByStockCode(stock_code)
    const resData = {
        code: 0,
        msg: 'success',
        count: users.count,
        data: users.rows
    }
    res.send(resData);
});
module.exports = router;
